package com.nekonomics
package api.dto.response

import domain.detail.OrderItemDetail
import types.Money

import zio.json.*
case class OrderItemDetailDto(
  skuId: Long,
  name: String,
  quantity: Int,
  price: Money,
  imageUrl: Option[String],
  subTotalPrice: Money
) derives JsonEncoder


object OrderItemDetailDto {
  def of(orderItem: OrderItemDetail) = {
    val stp = orderItem.price * orderItem.quantity
    OrderItemDetailDto(
      skuId = orderItem.skuId,
      name = orderItem.spuName,
      quantity = orderItem.quantity,
      price = orderItem.price,
      imageUrl = orderItem.imageUrl,
      subTotalPrice = stp
    )
  }
  
  
  
}
